/**
 * 初始化机构列表详情对话框
 */
var InfoInfoDlg = {
    infoInfoData : {}
};

/**
 * 清除数据
 */
InfoInfoDlg.clearData = function() {
    this.infoInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
InfoInfoDlg.set = function(key, val) {
    this.infoInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
InfoInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
InfoInfoDlg.close = function() {
    parent.layer.close(window.parent.Info.layerIndex);
}

/**
 * 收集数据
 */
InfoInfoDlg.collectData = function() {
    this.set('id').set('orgName').set('contactPeople').set('contactPhone').set('qq').set('mail').set('city').set('website').set('detAddress').set('introduce').set('companyPicUrl').set('introduceKey').set('assessScore').set('searchNumber').set('orgTel').set('picIdCardZ').set('picIdCardF').set('infoDetailImage1').set('infoDetailImage2')
        .set('infoDetailImage3').set('picBusinessLicence').set('upLoadPath').set('infoPic');
}

/**
 * 提交添加
 */
InfoInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/info/add", function(data){
        Feng.success("添加成功!");
        window.parent.Info.table.refresh();
        InfoInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.infoInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
InfoInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/info/update", function(data){
        Feng.success("修改成功!");
        window.parent.Info.table.refresh();
        InfoInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.infoInfoData);
    ajax.start();
}

$(function() {
    var infoDetailImage1Up = new $WebUpload("infoDetailImage1",Feng.ctxPath + '/info/upload');
    var infoDetailImage2Up = new $WebUpload("infoDetailImage2",Feng.ctxPath + '/info/upload');
    var infoDetailImage3Up = new $WebUpload("infoDetailImage3",Feng.ctxPath + '/info/upload');
    var infoPicUp = new $WebUpload("infoPic",Feng.ctxPath + '/info/upload');
    infoDetailImage1Up.init();
    infoDetailImage2Up.init();
    infoDetailImage3Up.init();
    infoPicUp.init();
});
